:root {
  --primary-color: #007bff;
  --primary-hover: #0056b3;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-color: #333;
  --text-secondary: #666;
  --border-color: #e9ecef;
  --danger-color: #dc3545;
  --success-color: #28a745;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  padding: 0;
}

/* Drop Zone */
#dropZone {
  background-color: var(--card-bg);
  border: 2px dashed var(--primary-color);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin: 20px;
  transition: all 0.3s ease;
  cursor: pointer;
}

#dropZone:hover,
#dropZone.dragover {
  background-color: #e3f2fd;
  border-color: var(--primary-hover);
}

#dropZone h1 {
  font-size: 1.2rem;
  margin: 10px 0;
  color: var(--text-color);
}

#dropZone h2 {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: normal;
}

.svg_icon {
  width: 48px;
  height: 48px;
  fill: var(--primary-color);
  margin-bottom: 10px;
}

.btn-mods {
  margin-top: 15px;
}

.btn {
  display: inline-block;
  padding: 8px 20px;
  background-color: var(--primary-color);
  color: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: var(--primary-hover);
}

/* Loading */
.loading {
  text-align: center;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.process-bar-item {
  margin-top: 10px;
  background: #eee;
  border-radius: 4px;
  height: 24px;
  position: relative;
  overflow: hidden;
}

.process-bar-inner {
  height: 100%;
  background: var(--success-color);
  width: 0;
  transition: width 0.2s;
}

.process-bar-fileinfo {
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #333;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

.fileinfo {
  display: flex;
  justify-content: space-between;
  flex: 1;
}

/* Path Bar */
.path-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}

.current-path {
  font-size: 1.1rem;
  color: var(--text-secondary);
  word-break: break-all;
  flex: 1;
  margin-right: 15px;
  margin-bottom: 0;
}

/* File List */
.file-list {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.diritem {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.1s;
}

.diritem:last-child {
  border-bottom: none;
}

.diritem:hover {
  background-color: #f1f3f5;
}

.col1 {
  flex: 1;
  min-width: 0;
  padding-right: 15px;
}

.col1 a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  display: block;
  white-space: pre-wrap;
}

.col1 a:hover {
  color: var(--primary-color);
}

.col2 {
  width: 80px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 30px;
}

.col3 {
  width: 150px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-right: 15px;
  line-height: 30px;
}

.col_del,
.col_play_pause {
  width: 40px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.del_btn,
.play_pause_btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  /* padding: 5px; */
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

.del_btn:hover {
  color: var(--danger-color);
  background-color: rgba(220, 53, 69, 0.1);
}

.play_pause_btn:hover {
  color: var(--primary-color);
  background-color: rgba(0, 106, 219, 0.1);
  transform: scale(1.3);
}

.play_pause_btn {
  color: var(--primary-color);
}

.del_btn svg,
.play_pause_btn svg {
  width: 18px !important;
  height: 18px !important;
  color: var(--primary-color) !important;
  display: block;
}

/* Video Player */
#video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#video-container.active {
  opacity: 1;
  pointer-events: auto;
}

video {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

#close-video {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 10px;
  z-index: 1001;
}

/* Header */
.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-item {
  cursor: pointer;
  user-select: none;
  align-items: center;
}

.header-item:hover {
  color: var(--primary-color);
}

.sort-icon::after {
  content: '↕';
  margin-left: 5px;
  font-size: 0.8em;
  opacity: 0.3;
}

.header-item.asc .sort-icon::after {
  content: '↑';
  opacity: 1;
}

.header-item.desc .sort-icon::after {
  content: '↓';
  opacity: 1;
}

/* Mobile Sort Bar */
.mobile-sort-bar {
  display: none;
}

.sort-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-btn.active {
  background-color: var(--primary-color);
  color: white;
  font-weight: 500;
}

.sort-btn.asc::after {
  content: ' ↑';
}

.sort-btn.desc::after {
  content: ' ↓';
}

/* Grid View */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  padding: 15px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius);
  transition: background-color 0.2s;
  position: relative;
}

.grid-item:hover {
  background-color: #f1f3f5;
}

.grid-thumb-container {
  width: 80px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  position: relative;
}

.preview-thumbnail {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-thumbnail img,
.preview-thumbnail video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.preview-thumbnail.is-icon svg {
  width: 60px;
  height: 60px;
  color: var(--text-secondary);
}

.preview-thumbnail.is-folder svg {
  width: 70px;
  height: 70px;
  color: #ffd700;
  fill: #ffd700;
  fill-opacity: 0.2;
}

.grid-name {
  font-size: 0.85rem;
  text-align: center;
  word-break: break-all;
  max-width: 100%;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-item:hover .grid-del-btn {
  opacity: 1;
}



#video-container.active {
  opacity: 1;
  pointer-events: auto;
}

video {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

#close-video {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 10px;
  z-index: 1001;
}

/* Header */
.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-item {
  cursor: pointer;
  user-select: none;
  align-items: center;
}

.header-item:hover {
  color: var(--primary-color);
}

.sort-icon::after {
  content: '↕';
  margin-left: 5px;
  font-size: 0.8em;
  opacity: 0.3;
}

.header-item.asc .sort-icon::after {
  content: '↑';
  opacity: 1;
}

.header-item.desc .sort-icon::after {
  content: '↓';
  opacity: 1;
}

/* Mobile Sort Bar */
.mobile-sort-bar {
  display: none;
}

.sort-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-btn.active {
  background-color: var(--primary-color);
  color: white;
  font-weight: 500;
}

.sort-btn.asc::after {
  content: ' ↑';
}

.sort-btn.desc::after {
  content: ' ↓';
}

/* Grid View */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  padding: 15px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius);
  transition: background-color 0.2s;
  position: relative;
}

.grid-item:hover {
  background-color: #f1f3f5;
}

.grid-thumb-container {
  width: 80px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  position: relative;
}

.preview-thumbnail {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-thumbnail img,
.preview-thumbnail video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.preview-thumbnail.is-icon > svg {
  width: 60px;
  height: 60px;
  color: var(--text-secondary);
}

.preview-thumbnail.is-folder > svg {
  width: 70px;
  height: 70px;
  color: #ffd700;
  fill: #ffd700;
  fill-opacity: 0.2;
}

.grid-name {
  font-size: 0.85rem;
  text-align: center;
  word-break: break-all;
  max-width: 100%;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: all 0.2s;
}
.play-overlay:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

/* Global Styles for Grid Items */
.play-overlay svg {
  width: 18px;
  height: 18px;
  margin-left: 2px;
  fill: white;
}

.grid-audio-btn {
  pointer-events: auto;
  cursor: pointer;
}

.grid-audio-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%) scale(1.1);
}

.grid-del-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: #666;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transition: all 0.2s;
}

.grid-item:hover .grid-del-btn {
  opacity: 1;
}

.grid-del-btn:hover {
  background: var(--danger-color);
  color: white;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .file-list-header {
    display: none !important;
  }

  .path-bar .btn {
    align-self: flex-end;
  }

  .mobile-sort-bar {
    display: flex !important;
    justify-content: space-between;
    margin: 0 10px 15px 10px;
    background: var(--card-bg);
    padding: 5px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .diritem {
    flex-wrap: wrap;
  }

  .col1 {
    width: 100%;
    flex: none;
    margin-bottom: 5px;
  }

  .col2 {
    text-align: left;
    margin-right: auto;
  }

  .grid-del-btn {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
  }
}